
import org.junit.jupiter.api.Test;
import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.nio.file.attribute.UserPrincipalNotFoundException;

public class SocketTest {
    public static void main(String[] args) throws UnknownHostException {
        System.out.println(InetAddress.getLocalHost().getHostAddress());
        //getAddress返回的是byte[]类型的字节码地址
        //而getHostAddress返回的是string类型的ip地址
    }

    @Test
    public void fun(){

        String s ="c=User&a=login?username=admin&password=admin123";
//        int firstDao = data.indexOf("&");
//        int secondDao = data.indexOf("&",firstDao+1);
//        System.out.println(data.substring(data.indexOf("=")+1,firstDao));
//        System.out.println(data.substring(firstDao+3,data.indexOf("?")));
        int den = s.indexOf('=');
        int ait = s.indexOf('&');
        int ait1 = s.indexOf('&',ait+1);
        int den1=s.indexOf('=',den+1);
        int den2=s.indexOf('=',den1+1);
        int den3=s.indexOf('=',den2+1);
        int wen = s.indexOf('?');
        String username = s.substring(den2+1,ait1);
        String password = s.substring(den3+1);

        System.out.println(username+" "+password);
    }
}
